package org.onion.pattern.kit.validation.annotation.validator;


import org.onion.pattern.kit.validation.annotation.IsNumeric;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import org.apache.commons.lang3.StringUtils;

/**
 * 全数字
 *
 */
public class NumericValidator implements ConstraintValidator<IsNumeric, String> {
    @Override
    public void initialize(IsNumeric isNumeric) {

    }

    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        if (StringUtils.isBlank(s)) {
            return true;
        } else if (StringUtils.isNumeric(s)) {
            return true;
        }
        return false;
    }

}
